package org.udr.query;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;



public class Query {
	
	private String name;
	
    private final String rootEntityName;

    private final Map<String,Join> joins = new HashMap<String, Join>();
    
    private final List<Projection> projectionList = new ArrayList<Projection>();
    
    private Junction criteria;

    public Query (String rootEntityName) {
    	this.rootEntityName = rootEntityName;
    }
    
    public Junction getCriteria () {
        return criteria;
    }

    public void setCriteria (Junction val) {
        this.criteria = val;
    }

    public String getName () {
        return name;
    }

    public void setName (String val) {
        this.name = val;
    }

    public String getRootEntityName () {
        return rootEntityName;
    }

	public Collection<Join> getJoins() {
		return joins.values();
	}

	public void addJoin (Join join) {
		this.joins.put (join.getAlias(),join);
	}

	public List<Projection> getProjectionList() {
		return projectionList;
	}
	
	public void addProjection(Projection projection){
		projectionList.add(projection);
	}
	
	public void removeProjection(Projection projection){
		projectionList.remove(projection);
	}
}

